/**
 * Created by Administrator on 2019/9/13.
 */
// var money = document.querySelector(".qian");
// var iptQian = document.querySelector(".iptQian")
// var sum = document.querySelector(".sum");
// var sun = document.querySelector(".jin")
// var arr = [1.68];
// function d() {
//     sum.innerHTML = Number(money.innerHTML)*Number(iptQian.value)
//     for(var i = 0;i<arr.length;i++){
//         sun.innerHTML = arr[i] * Number(iptQian.value)
//     }
// }
// sum.innerHTML = Number(money.innerHTML)*Number(iptQian.value)
// for(var i = 0;i<arr.length;i++){
//     sun.innerHTML = arr[i] * Number(iptQian.value)
// }
// iptQian.addEventListener("blur",function () {
//     d()
// })
//
// let li = document.querySelector('#table li');
//
// for(let k = 0;i<li.length;k++){
//
// }

function s() {
    let tr = document.querySelectorAll('#table .tr');
    let allCount = document.querySelector('#allCount');
    let allCountNum = 0;
    for(let i = 0;i<tr.length;i++){
        var price = tr[i].children[2].children[0].children[0].innerHTML;
        console.log(price)
        var num = tr[i].children[3].children[0].children[0].value;
        console.log(num)
        var count = tr[i].children[4].children[0].innerHTML = (price * num).toFixed(2);
        console.log(count)
        allCountNum += Number(count)
    }
    allCount.innerHTML = allCountNum.toFixed(2);
}
s();

let ipt = document.querySelectorAll('#table .num')
for(let j = 0; j<ipt.length;j++){
    ipt[j].addEventListener('change',s)
}

let del = document.querySelectorAll('.del');
for (let k = 0; k<del.length;k++){
    del[k].addEventListener('click',function () {
        var tbody = document.querySelector('#table tbody');
        tbody.removeChild(this.parentNode.parentNode)
        s()
    })
}




